"use strict";
function sayHi3() {
    return "这是一段字符串文本";
}
var hi = sayHi3();
function countSum(x, y) {
    return x + y;
}
var sumInput = countSum(1, 3);
console.log(sumInput);
//参数默认值
function helloasd(name) {
    if (name)
        return console.log("my name is " + name);
    console.log("my name is WXS");
}
helloasd();
function helloasd2(name) {
    if (name === void 0) { name = "WXS"; }
    if (name)
        return console.log("my name is " + name);
}
helloasd2();
function buyGun(gunName, count) {
    console.log("\u6709\u773C\u5149~[" + gunName + "]\u662F\u6751\u91CC\u6700\u4EAE\u7684\u67AA,\u9001\u4F60[" + count + "]\u628A,\u6211\u4EECP\u57CE\u6765\u76F8\u89C1");
}
buyGun("M416", 3);
//可选参数参数
function buyGun1(gunName, count) {
    console.log("\u6709\u773C\u5149~[" + gunName + "]\u662F\u6751\u91CC\u6700\u4EAE\u7684\u67AA,\u9001\u4F60[" + (count ? count : 1) + "]\u628A,\u6211\u4EECP\u57CE\u6765\u76F8\u89C1");
}
buyGun1("M416", 5);
//函数默认值
function buyGun3(gunName, count) {
    if (gunName === void 0) { gunName = "M416"; }
    if (count === void 0) { count = 1; }
    console.log("\u6709\u773C\u5149~[" + gunName + "]\u662F\u6751\u91CC\u6700\u4EAE\u7684\u67AA,\u9001\u4F60[" + count + "]\u628A,\u6211\u4EECP\u57CE\u6765\u76F8\u89C1");
}
// buyGun3("AK47", 5);
//前面不传写undefined后面传
buyGun3(undefined, 3);
//剩余参数
function addSum(x, y) {
    var restOfNum = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        restOfNum[_i - 2] = arguments[_i];
    }
    //创建一个求和变量保存求和结果,将x和y的值求和后传入
    var resNum = x + y;
    //使用for of遍历剩余参数,并累加到求和变量中
    for (var _a = 0, restOfNum_1 = restOfNum; _a < restOfNum_1.length; _a++) {
        var ele = restOfNum_1[_a];
        resNum += ele;
    }
    //将结果打印
    console.log("打印结果:" + resNum);
}
addSum(1.2, 2);
addSum(1, 23, 4, 5, 6, 7, 8, 9, 0);
